<ul id="tracking" class="btns b10">
	<li class="btn left c"><a href="javascript:;">コードを追加</a></li>
	<li class="btn right c"><a href="javascript:;">空のコードを削除</a></li>
</ul>
<div id="codearea">
{if isset($forms.t_id)}
	{foreach item=t_id key=n from=$forms.t_id}
		<table class="formTable">
		<tbody>
			<tr>
				<th>名称</th>
				<td>
					<input type="hidden" name="forms[t_id][]" value="{$t_id}" />
					<input type="text" name="forms[t_name][]" class="text" value="{$forms.t_name[$n]}" />
				</td>
			</tr>
			<tr>
				<th>title</th>
				<td>
					<textarea name="forms[t_code][]">{$forms.t_code[$n]}</textarea>
				</td>
			</tr>
			{if isset($err.tracking[$n])}<tr><td colspan="2">{$validate->getMessages($err.tracking[$n]) nofilter}</td></tr>{/if}
		</tbody>
		</table>
	{/foreach}
{/if}
</div>
<script type="text/javascript">
$('#tracking .left a').click(function(){
	$('#codearea').prepend('<table class="formTable"><tbody><tr><th>名称</th><td><input type="hidden" name="forms[t_id][]" value="" /><input type="text" name="forms[t_name][]" class="text" value="" /></td></tr><tr><th>title</th><td><textarea name="forms[t_code][]"></textarea></td></tr></tbody></table>');
})

$('#tracking .right a').click(function(){
	$('#codearea textarea').each(function(){
		if(!$(this).val()){ $(this).parents("table").remove(); }
	});
})
</script>